<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/4/24/024
 * Time: 22:38
 */
namespace app\api\model;
use think\Model;

class LoginLog extends Model
{
    /**
    * 添加登陆设备
    * @param mid int 会员表id
    * @param udid string 设备udid
    * @param is_tourist int 是否是游客
    * @param request array 参数数组
    * @return bool 
    */
    public function _addLog($mid, $udid, $is_tourist, $request){
        $data = [
            'mid' => $mid,
            'udid' => $udid,
            'app_name' => $request['app_name'],
            'app_version' => $request['app_version'],
            'sys_name' => $request['sys_name'],
            'sys_version' => $request['sys_version'],
            'sys_language' => $request['sys_language'],
            'mobile_model' => $request['mobile_model'],
            'unique_identification' => $request['unique_identification'],
            'country' => $request['country'],
            'operator' => $request['operator'],
            'mcc' => $request['mcc'],
            'mnc' => $request['mnc'],
            'log' => $request['log'],
            'is_tourist' => $request['is_tourist'],
            'lat' => $request['lat'],
            'ip' => ip2long($request['ip']),
            'created' => time()
        ];
        /*sys_name
        sys_version
        sys_language
        mobile_model
        unique_identification
        country
        operator
        mcc
        mnc
        ip*/
        $ret = $this->insert($data);
        if(!$ret){
            $this->error = '设备日志添加失败';
            return false;
        }
        
        return true;
    }
    
    
}